<html>
	<head>

		<script type="text/javascript">

		function replaceWhiteSpace(text)
		{
			text = text.replace(/[\t ]/g,"&nbsp;")
			return text;
		};

		function onClick()
		{
			  var text = "We are living in an yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
			  	var output = document.getElementById('output');
		        var p = document.createElement("p");
				var text = document.createTextNode(replaceWhiteSpace(text));
				p.appendChild(text);
				output.appendChild(p);		     
		};
		</script>
		<title></title>
	</head>
	<body>
		
		
		<pre>
	Text: We are living in an yellow submarine. 
	We don't have anything else. Inside the submarine is very tight. 
	So we are drinking all the day. We will move out of it in 5 days.	
		</pre>
		<button onclick="onClick()" id="buttonOne">Replace</button>
		<p>
			Output
		</p>
		<div id="output"></div>
	</body>
</html>